$newid = wfInsertId();
$this->mTitle->resetArticleID( $newid );
+ // Purge related entries in links cache on new page, to heal broken links
+ $ptitle = wfStrencode( $ttl );
+ wfQuery("DELETE linkscc FROM linkscc,brokenlinks ".
+ "WHERE lcc_pageid=bl_from AND bl_to='{$ptitle}'", DB_WRITE);
+
$sql = "INSERT INTO recentchanges (rc_timestamp,rc_cur_time," .
"rc_namespace,rc_title,rc_new,rc_minor,rc_cur_id,rc_user," .
"rc_user_text,rc_comment,rc_this_oldid,rc_last_oldid,rc_bot) VALUES (" .
$sql = "UPDATE recentchanges SET rc_cur_time='{$now}' " .
"WHERE rc_cur_id=" . $this->getID();
wfQuery( $sql, DB_WRITE, $fname );
+
+ // Purge related entries in link cache when a page change
+ // (probably just affects anything when article changes stub state)
+ $pageid=$this->getID();
+ wfQuery("DELETE linkscc FROM linkscc,links ".
+ "WHERE lcc_title=links.l_from AND l_to={$pageid}", DB_WRITE);
+
}
if( $wgDBtransactions ) {
$sql = "COMMIT";
# Finally, clean up the link tables
if ( 0 != $id ) {
+
+ // Purge related entries in links cache on delete,
+ wfQuery("DELETE linkscc FROM linkscc,links ".
+ "WHERE lcc_title=links.l_from AND l_to={$id}", DB_WRITE);
+ wfQuery("DELETE FROM linkscc WHERE lcc_title='{$t}'", DB_WRITE);
+
$t = wfStrencode( $title->getPrefixedDBkey() );
$sql = "SELECT l_from FROM links WHERE l_to={$id}";
$res = wfQuery( $sql, DB_READ, $fname );
wfProfileIn( $fname );
# Note -- $fromtitle is a Title *object*
$dbkeyfrom = wfStrencode( $fromtitle->getPrefixedDBKey() );
+
+
+ $res = wfQuery("SELECT lcc_cacheobj FROM linkscc WHERE lcc_title = '{$dbkeyfrom}'",
+ DB_READ);
+ $row = wfFetchObject( $res );
+ if( $row != FALSE){
+ $cacheobj = gzuncompress( $row->lcc_cacheobj );
+ $cc = unserialize( $cacheobj );
+ $this->mGoodLinks = $cc->mGoodLinks;
+ $this->mBadLinks = $cc->mBadLinks;
+ $this->mPreFilled = true;
+ wfProfileOut( $fname );
+ return;
+ }
+
+
$sql = "SELECT cur_id,cur_namespace,cur_title
FROM cur,links
WHERE cur_id=l_to AND l_from='{$dbkeyfrom}'";
$this->mOldBadLinks = $this->mBadLinks;
$this->mOldGoodLinks = $this->mGoodLinks;
$this->mPreFilled = true;
-
+
+ // put fetched link data into cache
+ $serCachegz = wfStrencode( gzcompress( serialize( $this ), 3) );
+ wfQuery("REPLACE INTO linkscc VALUES({$id}, '{$dbkeyfrom}', '{$serCachegz}')",
+ DB_WRITE);
+
wfProfileOut( $fname );
}
$this->mTitleEnc = wfStrencode( $title );
}
+
function doUpdate()
{
global $wgUseBetterLinksUpdate, $wgLinkCache, $wgDBtransactions;
/* Update link tables with outgoing links from an updated article */
/* Relies on the 'link cache' to be filled out */
+ // Make sure links cache is regenerated on next load
+ wfQuery("DELETE FROM linkscc WHERE lcc_title = '{$safeTitle}'", DB_WRITE);
+
if ( !$wgUseBetterLinksUpdate ) {
$this->doDumbUpdate();
return;